package com.sky.controller.admin;

import com.sky.dto.DishPageQueryDTO;
import com.sky.dto.SetmealDTO;
import com.sky.entity.Dish;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.DishService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/setmeal")
@Api(tags = "套餐管理")
@Slf4j
public class DishController {
    @Autowired
    private DishService dishService;

    @GetMapping("/page")
    @ApiOperation("套餐分页查询")
    public Result<PageResult> page(DishPageQueryDTO queryDTO){
        log.info("套餐分页查询...{}",queryDTO);
        return dishService.queryDish(queryDTO);
    }

    @PostMapping
    @ApiOperation("新增套餐")
    public Result<String> saveDish(SetmealDTO setmealDTO){
        return Result.success();
    }

    @PostMapping("/status/{status}")
    @ApiOperation("修改套餐状态")
    public Result<String> status(@PathVariable Integer status, int id){
        log.info("修改套餐状态...{}",id);
        dishService.updatastatus(status,id);
        return Result.success();
    }

    @DeleteMapping
    @ApiOperation("删除套餐")
    public Result<String> delete(@RequestParam("ids") List<Integer> ids){
        log.info("删除套餐...");
        dishService.deletes(ids);
        return Result.success();
    }
}
